import { Context } from "./UseReducerFun"
import { useContext } from "react"

export default function ReducerTwo() {
    const context = useContext(Context)
    const changeArray = () => {
        context.dispatch({ type: "changeArray", payload: [20,80] })
    }
    return <div>
        <div>son2:{context.objRes.num}</div>
        <button onClick={() => context.dispatch({type: 'add'})}>+1</button>
        <button onClick={() => context.dispatch({ type: 'del'})}>-1</button>
        <button onClick={changeArray}>修改数组</button>
    </div>
}